<template>
  <div class="warehouseTakeStockQuery">
    <div class="wdq-top">
      <div>
        <p>仓库</p>
        <el-input
          v-model="warehouseNo"
          @blur="warehouseNoBlur"
          style="width:60px;margin-right:10px;"
        ></el-input>
        <el-select
          v-model="warehouseName"
          style="width:100px;"
          @change="
            e => {
              this.warehouseNo = e
            }
          "
        >
          <el-option
            v-for="item in warehouseNoList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>

        <p>款号</p>
        <!-- <el-input class="wd" v-model="kindsNumber"></el-input> -->
        <el-autocomplete
          class="wd"
          clearable
          v-model="kindsNumber"
          :fetch-suggestions="querySearch"
        >
        </el-autocomplete>

        <p>单号</p>
        <el-input v-model="receiptsNumber" class="wd"></el-input>

        <p>品牌</p>
        <el-select v-model="brandedName" class="wd">
          <el-option
            v-for="item in brandedNameList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>

        <p>季度</p>
        <el-select v-model="quarterIdList" class="wd" multiple collapse-tags>
          <el-option
            v-for="item in quarterIdListL"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>

        <p>盘点序号</p>
        <el-input class="wd" v-model="searchSequence"></el-input>

        <p>盘差序号</p>
        <el-input class="wd" disabled></el-input>
      </div>

      <div style="margin-top:10px;">
        <p>日期</p>
        <el-date-picker
          unlink-panels
          v-model="timeData"
          type="daterange"
          value-format="yyyy-MM-dd"
          format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
        <p>截止日期</p>
        <el-date-picker
          disabled
          value-format="yyyy-MM-dd"
          v-model="checkDate"
          type="date"
        >
        </el-date-picker>
      </div>
    </div>

    <div class="wdq-btn">
      <div>
        <el-button @click="query" type="primary" icon="el-icon-search"
          >查询</el-button
        >
        <el-button @click="confirm" :disabled="Dis2" icon="el-icon-circle-check"
          >确认</el-button
        >
        <el-button @click="Shgd" :disabled="Dis3" icon="el-icon-edit-outline"
          >改单</el-button
        >
        <!-- <el-button @click="()=>{this.print='block'}" icon="el-icon-printer">列印</el-button> -->
        <el-button v-print="'#tip1'" icon="el-icon-printer">列印</el-button>
        <el-button :disabled="Dis3" @click="dele" icon="el-icon-delete"
          >删除</el-button
        >
      </div>
      <div>
        <el-button
          @click="automatic"
          style="margin-right:15px;"
          type="primary"
          plain
          :disabled="Dis"
          >自动盘差</el-button
        >
        <el-checkbox v-model="checked" border :disabled="Dis1"
          >差量查询</el-checkbox
        >
      </div>
    </div>

    <div class="wdq-tab">
      <div>
        <el-table
          id="tip"
          height="66vh"
          :data="tableData"
          highlight-current-row
          @row-click="rowClick"
          :header-cell-style="{
            background: '#f4f4f4',
            padding: 0,
            height: '40px'
          }"
          :cell-style="{ padding: 0, height: '26px' }"
          style="width: 100%"
        >
          <el-table-column prop="sequence" label="仓库盘点序号" width="140px">
          </el-table-column>
          <el-table-column prop="warehouseNo" label="仓库编号">
          </el-table-column>
          <el-table-column prop="totalNumber" label="盘点数量">
          </el-table-column>
          <el-table-column prop="checkTime" label="盘点日期" width="100px">
          </el-table-column>
        </el-table>
        <!-- 分頁 -->
        <el-pagination
          small
          background
          layout="prev, pager, next, jumper, sizes"
          :page-sizes="[20, 50, 100, 200]"
          :page-size="limit"
          :page-count="pagesNum"
          :total="dataLen"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
        >
        </el-pagination>
      </div>

      <div>
        <el-table
          id="tip1"
          height="66vh"
          highlight-current-row
          :data="tableData1"
          :header-cell-style="{
            background: '#f4f4f4',
            padding: 0,
            height: '40px'
          }"
          :cell-style="{ padding: 0, height: '26px' }"
          style="width: 100%"
        >
          <template v-for="i in tList">
            <el-table-column
              show-overflow-tooltip
              :prop="i.prop"
              :key="i.prop + Math.random()"
              :label="i.label"
              :width="i.width"
            >
            </el-table-column>
          </template>
        </el-table>
        <!-- 分頁 -->
        <el-pagination
          small
          background
          layout="prev, pager, next, jumper, sizes"
          :page-sizes="[20, 50, 100, 200]"
          :page-size="limit1"
          :page-count="pagesNum1"
          :total="dataLen1"
          @current-change="handleCurrentChange1"
          @size-change="handleSizeChange1"
        >
        </el-pagination>
      </div>
    </div>

    <div class="tip" :style="{ display: showTip }">
      <div>
        <p>{{ text }}</p>
        <i
          class="el-icon-close"
          @click="
            () => {
              this.showTip = 'none'
            }
          "
        ></i>
      </div>

      <div class="tip1" :style="{ display: showTip1 }">
        <div>
          <p>你确定要以此盘差数据作为仓库实存数据吗？</p>
          <p>特别慎重此数据的保存！</p>
        </div>
        <div>
          <el-button
            @click="
              () => {
                this.showTip = 'none'
              }
            "
            >取消</el-button
          >
          <el-button @click="nextBox" type="primary">确定</el-button>
        </div>
      </div>

      <div class="tip1" :style="{ display: showTip2 }">
        <div>
          <p>请输入登录密码</p>
          <el-input
            v-model="password"
            type="password"
            auto-complete="off"
            @keyup.enter.native="testpwd"
          ></el-input>
        </div>
        <div>
          <el-button @click="testpwd" type="primary">确定</el-button>
        </div>
      </div>

      <div class="tip1" :style="{ display: showTip3 }">
        <div>
          <p>没有检索到任何数据！</p>
        </div>
        <div>
          <el-button
            @click="
              () => {
                this.showTip = 'none'
              }
            "
            type="primary"
            >确定</el-button
          >
        </div>
      </div>

      <div class="tip1" :style="{ display: showTip4 }">
        <div>
          <p>自动盘差处理保存成功！</p>
          <p>{{ tips }}</p>
        </div>
        <div>
          <el-button
            @click="
              () => {
                this.showTip = 'none'
              }
            "
            type="primary"
            >确定</el-button
          >
        </div>
      </div>
    </div>

    <!-- 列印 -->
    <!-- <pr-int
    class="print"
    :style="{display:print}"
    @closeprint="()=>{this.print='none'}">
    </pr-int> -->

    <!-- 改单密码验证 -->
    <verify-password
      :style="{ display: showpwd }"
      @closepwd="
        () => {
          this.showpwd = 'none'
        }
      "
      @showRevision="showRevision"
    >
    </verify-password>

    <wchange-Od
      :style="{ display: showod }"
      @closewod="
        () => {
          this.showod = 'none'
        }
      "
      :showData="this.details1"
      @Save="Save"
      @odChange="odChange"
    >
    </wchange-Od>

    <foot-view class="footView">
      <div slot="text">
        <el-popover
          placement="top-start"
          width="120"
          max-height="100px"
          trigger="click"
        >
          <el-checkbox-group v-model="selectHeaderList">
            <el-checkbox
              v-for="i in headerList"
              :label="i.value"
              :key="i.value"
              style="margin-bottom:7px"
            ></el-checkbox>
          </el-checkbox-group>
          <i slot="reference" class="el-icon-date"> 表头配置</i>
        </el-popover>
        <span>数据库：{{ jxQuarter }}</span>
      </div>
    </foot-view>
  </div>
</template>

<script>
import verifyPassword from '../../../components/VerifyPassword'
import footView from '../../../components/FootView'
import wchangeOd from './childComp/WchangeOd'
import enterUp from '../../../components/mixins/enterUp'
import today from '../../../components/mixins/today'
import { getBranded } from '../../../network/branded'
import { getWarehouse } from '../../../network/warehouse'
import { getQuarter, getNumber, isEnough } from '../../../network/quarter'
import {
  InventoryQuary,
  InventoryChange,
  Automatic,
  testPwd,
  getDifference,
  confirmInventory
} from '../../../network/manufacturer'
export default {
  name: 'warehouse_take_stock_query',
  mixins: [today, enterUp],
  created() {
    let jxQuarterVal = document.cookie.match(RegExp('jxQuarter' + '=([^;]+)'))
    this.jxQuarter = jxQuarterVal ? jxQuarterVal[1] : null
    
    this.inpList = this.getInput()
    this.tList = this.tList1
    // this.timeData = [this.getLastWeek(),this.getNowTime()];
    this.checkDate = this.getNowTime()

    // 获取仓库信息
    getWarehouse().then(res => {
      console.log(res.data)
      let list = res.data.data
      list.sort((a, b) => {
        return a.no.localeCompare(b.no)
      })
      list.forEach(e => {
        this.warehouseNoList.push({ value: e.no, label: e.name })
        if (e.isMainWarehouse) {
          this.warehouseNo = e.no
          this.warehouseName = e.name
        }
      })
    })
    //季度
    getQuarter().then(res => {
      console.log(res.data)
      let qList = res.data.data
      qList.forEach(e => {
        this.quarterIdListL.push({ label: e.name, value: e.name })
      })
    })

    //品牌
    getBranded().then(res => {
      console.log(res)
      res.data.data.forEach(e => {
        this.brandedNameList.push({ value: e.name, label: e.name })
      })
    })
    //款号
    getNumber(JSON.stringify([''])).then(res => {
      console.log(res.data)
      if (res.data.code == 200) {
        res.data.data.forEach(e => {
          this.kindsNumberList.push({
            value: e.styleNumber,
            label: e.styleNumber
          })
        })
      }
    })
  },
  data() {
    return {
      tips: '',
      Dis2: false,
      Dis3: false,
      Dis1: true,
      Dis: true,
      selectHeaderList: [],
      headerList: [],
      jxQuarter: null,
      // jxQuarter: documnt.cookie.match(RegExp('jxQuarter' + '=([^;]+)'))[1],
      allData1: [],
      allData: [],
      // 总数据条数
      dataLen1: 0,
      // 总页码
      pagesNum1: 0,
      // 分页条数
      limit1: 20,
      // 当前页码
      currentPage1: 1,

      // 总数据条数
      dataLen: 0,
      // 总页码
      pagesNum: 0,
      // 分页条数
      limit: 20,
      // 当前页码
      currentPage: 1,
      // print:'none',
      showod: 'none',
      showpwd: 'none',
      // SpOrder:'none',
      kindsNumberList: [],
      inpList: [],
      password: '',
      quarterIdList: [],
      quarterIdListL: [],
      checked: false,
      text: '自动盘差',
      showTip: 'none',
      showTip1: 'block',
      showTip2: 'none',
      showTip3: 'none',
      showTip4: 'none',

      checkDate: [],
      details: [],
      details1: {},
      Aff: [],
      warehouseNo: '',
      warehouseName: '',
      warehouseNoList: [],
      sequence: '',
      searchSequence: '',
      receiptsNumber: '',
      kindsNumber: '',
      timeData: [],
      brandedName: '',
      brandedNameList: [],
      // selectHeaderList:[],
      tableData: [],
      tableData1: [],
      tableData2: [],
      tableData3: [],
      tList: [],
      tList1: [
        { prop: 'sequence', label: '仓库盘点序号', width: '140px' },
        { prop: 'receiptsNumber', label: '单号', width: '150px' },
        { prop: 'warehouseNo', label: '仓库编号', width: '80px' },
        { prop: 'warehouseName', label: '仓库' },
        { prop: 'kindsNumber', label: '货号', width: '135px' },
        { prop: 'stockingNumber', label: '盘点数量' },
        { prop: 'stockingMoney', label: '盘点金额' },
        { prop: 'sellingPrice', label: '售价' },
        { prop: 'quarterName', label: '季度', width: '80px' },
        { prop: 'operator', label: '操作员', width: '80px' },
        { prop: 'enteringTime', label: '录入日期', width: '100' }
      ],
      tList2: [
        { prop: 'warehouseNo', label: '仓库编号' },
        { prop: 'warehouseName', label: '仓库' },
        { prop: 'kindsNumber', label: '货号' },
        { prop: 'number', label: '盘盈亏' },
        { prop: 'checkNumber', label: '盘点' },
        { prop: 'repertoryNumber', label: '库存' },
        { prop: 'commodityName', label: '品名' },
        { prop: 'colorName', label: '颜色' }
      ]
    }
  },
  components: {
    footView,
    verifyPassword,
    wchangeOd
    // supplementOrder,
    // prInt
  },
  methods: {
    //确认
    confirm() {
      for (let u of this.Aff) {
        if (u.affirm == 1) {
          this.$message({
            type: 'info',
            message: '此单已确认!'
          })
          return
        }
      }
      if (this.sequence == '') {
        this.$message({
          type: 'warning',
          offset: 400,
          message: '请选中一条数据进行确认!'
        })
        return
      }
      this.$confirm(
        '确认后不可对此单进行改单,删单和补单操作 是否确认？',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).then(() => {
        confirmInventory({ sequence: this.sequence }).then(res => {
          console.log(res.data)
          if (res.data.code == 200) {
            for (let i of this.tableData) {
              if (this.sequence == i.sequence) {
                i.affirm = 1
              }
            }
            for (let i of this.tableData1) {
              if (this.sequence == i.sequence) {
                i.affirm = 1
              }
            }
            this.$message({
              type: 'success',
              offset: 400,
              message: '确认成功!'
            })
          } else {
            this.$message.error({
              offset: 400,
              message: '确认失败'
            })
          }
        })
      })
    },
    //左表当前页
    handleCurrentChange(val) {
      console.log(val)
      this.currentPage = val
      this.query()
    },
    //选择每页多少条
    handleSizeChange(val) {
      this.limit = val
      this.pagesNum = Math.ceil(this.dataLen / this.limit)
      this.query()
    },
    //右表当前页
    handleCurrentChange1(val) {
      this.currentPage1 = val
      this.tableData1 = this.allData1.slice(
        (this.currentPage1 - 1) * this.limit1,
        this.currentPage1 * this.limit1
      )
    },
    handleSizeChange1(val) {
      this.limit1 = val
      this.pagesNum1 = Math.ceil(this.dataLen1 / this.limit1)
      this.tableData1 = this.allData1.slice(
        (this.currentPage1 - 1) * this.limit1,
        this.currentPage1 * this.limit1
      )
      console.log(this.tab1Data)
    },

    dele() {
      for (let c of this.Aff) {
        if (c.affirm == 1) {
          this.$message({
            type: 'warning',
            offset: 400,
            message: '此单已确认，不可进行删除操作'
          })
          return
        }
      }
      if (this.details == '') {
        return
      }
      this.$router.push({
        path: '/warhous_delete',
        query: {
          type: 1,
          sequenceid: this.sequence,
          warehouseNo: this.warehouseNo
        }
      })
      this.$store.commit('addNav', {
        label: '仓库盘点查询删单',
        name: 'warhous_delete'
      })
    },
    querySearch(queryString, cb) {
      let kindsNumberList = this.kindsNumberList
      let results = queryString
        ? kindsNumberList.filter(this.createFilter(queryString))
        : kindsNumberList
      cb(results)
    },
    createFilter(queryString) {
      return composition => {
        return (
          composition.value.toLowerCase().indexOf(queryString.toLowerCase()) ==
          0
        )
      }
    },
    odChange(data) {
      console.log(data)
      InventoryChange(data).then(res => {
        console.log(res.data)
        if (res.data.code == 200) {
          this.$message({
            type: 'success',
            message: '改单成功!'
          })
        } else {
          this.$message.error({
            message: '改单失败'
          })
        }
      })
    },
    Save(data) {
      console.log(data)
      this.showod = 'none'
      InventoryChange(data).then(res => {
        console.log(res.data)
        if (res.data.code == 200) {
          this.$message({
            type: 'success',
            message: '保存成功!'
          })
        } else {
          this.$message.error({
            message: '保存失败'
          })
        }
      })
    },

    //自动盘差
    automatic() {
      // if(this.tableData1 == ''){
      //   this.$message({
      //     message: '请选择一条数据进行操作',
      //     type: 'warning'
      //   })
      //   return
      // }
      this.showTip3 = 'none'
      this.showTip4 = 'none'
      this.showTip1 = 'block'
      this.showTip = 'block'
    },
    //查询
    query() {
      console.log(this.timeData)
      let params = {
        warehouseNo: this.warehouseNo,
        kindsNumber: this.kindsNumber,
        receiptsNumber: this.receiptsNumber,
        brandedName: this.brandedName,
        quarterIdList: this.quarterIdList,
        sequence: this.searchSequence,
        checkDate:
          this.checkDate == null || this.checkDate == ''
            ? ''
            : this.checkDate + ' 23:59:59',
        startTime:
          this.timeData == null || this.timeData == ''
            ? ''
            : this.timeData[0] + ' 00:00:00',
        endTime:
          this.timeData == null || this.timeData == ''
            ? ''
            : this.timeData[1] + ' 23:59:59',
        'pageData.page': this.currentPage,
        'pageData.limit': this.limit
      }
      console.log(params)
      InventoryQuary(params).then(res => {
        console.log(res.data)
        if (res.data.data == null) {
          this.tableData = []
          this.tableData1 = []
          this.Dis1 = true
        } else {
          this.Dis1 = false
          for (let y of res.data.data) {
            y.checkTime = y.checkTime.slice(0, 10)
          }
          // this.tableData = res.data.data[0]
          // this.allData = res.data.data
          this.dataLen = res.data.total
          this.tableData = res.data.data
          // this.tableData = this.allData.slice((this.currentPage-1)*this.limit,this.currentPage*this.limit)
          if (this.checked) {
            this.isChecked()
          }
        }
      })
    },
    rowClick(e) {
      if (e.affirm == 1) {
        this.Dis2 = true
        this.Dis3 = true
      } else {
        this.Dis2 = false
        this.Dis3 = false
      }
      // this.Dis1 = false
      this.sequence = e.sequence
      this.details = e
      this.details1 = e
      this.Aff = [e]
      if (this.checked == false) {
        for (let u of e.warehouseCheckList) {
          u.enteringTime = u.enteringTime.slice(0, 10)
        }
        // this.tableData1 = e.warehouseCheckList
        this.allData1 = e.warehouseCheckList
        this.dataLen1 = this.allData1.length
        this.tableData2 = this.allData1.slice(
          (this.currentPage1 - 1) * this.limit1,
          this.currentPage1 * this.limit1
        )
        this.tableData1 = this.tableData2
      }

      return
      if (this.checked == true) {
        //点左表 差量查询 是勾选 就查询
        let kindsNumber = {}
        let warehouseMap = {}
        this.tableData1.forEach(e => {
          //tableData1 里 两个值 转成key:value
          kindsNumber[e.kindsNumber] = e.stockingNumber
          warehouseMap[e.kindsNumber] = e.warehouseName
        })
        let obj = {
          kindsNumberMap: kindsNumber,
          warehouseMap: warehouseMap,
          warehouseNo: this.warehouseNo,
          cutTime: this.checkDate,
          softwareCustomerId: document.cookie.match(
            RegExp('jxSoftWareCustomerId' + '=([^;]+)')
          )[1],
          startDate: this.timeData[0],
          endDate: this.timeData[1]
        }
        this.tList = this.tList2
        console.log(obj)
        console.log(JSON.stringify(obj))
        getDifference(JSON.stringify(obj)).then(res => {
          console.log(res.data)
          if (res.data.code == 200) {
            this.tableData3 = res.data.data
            this.tableData1 = this.tableData3
          }
        })
      }
    },

    nextBox() {
      this.showTip1 = 'none'
      this.showTip2 = 'block'
      this.text = '输入密码'
    },
    testpwd() {
      testPwd({ password: this.password }).then(res => {
        console.log(res.data)
        if (res.data.code == 200) {
          var ai = []
          var ao = []
          var kindsNumberNumberMap = {}
          var No = ''
          for (let a of this.tableData1) {
            //获取左表下 所有货号 数量
            ai.push(a.kindsNumber)
            ao.push(a.number)
            No = a.warehouseNo
          }
          for (let b in ai) {
            for (let c in ao) {
              if (b == c) {
                if (ao[c] < 0) {
                  kindsNumberNumberMap[ai[b]] = Math.abs(ao[c]) //Math.abs将负数转为正数
                }
                if (ao[c] > 0) {
                  kindsNumberNumberMap[ai[b]] = -ao[c]
                }
              }
            }
          }
          // console.log(kindsNumberNumberMap)
          let obj1 = { kindsNumberNumberMap, companyNo: No }
          // console.log(obj1)
          isEnough(JSON.stringify(obj1)).then(res => {
            //库存是否足够 /扣库存
            console.log(res.data)
            if (res.data.code == 200) {
              var InsufficientList = res.data.data //不足货号
              var List = [] //货号够

              // console.log(ai)
              if (InsufficientList == null) {
                //查库存是否足够 不足货号不为空
                let obj3 = {
                  cutTime: this.checkDate,
                  kindsNumberMap: kindsNumberNumberMap,
                  warehouseNo: No
                }
                console.log(obj3)
                Automatic(JSON.stringify(obj3)).then(res => {
                  console.log(res.data)
                  if (res.data.code == 200) {
                    var msgData = res.data.data
                    this.showTip2 = 'none'
                    this.showTip4 = 'block'
                    this.text = '提示信息'
                    this.tips = `盘差序号: ${msgData}`
                  } else {
                    this.showTip2 = 'none'
                    this.showTip3 = 'block'
                    this.text = '提示信息'
                  }
                })
                return
              }

              ai.forEach(e => {
                if (ai.includes(e) && !InsufficientList.includes(e)) {
                  List.push(e)
                }
              })
              console.log(List)

              if (List != '') {
                //货号够
                var kindsNumberNumberMap1 = {}
                for (let q of this.tableData1) {
                  for (let w of List) {
                    if (q.kindsNumber == w) {
                      if (q.number < 0) {
                        kindsNumberNumberMap1[q.kindsNumber] = Math.abs(
                          q.number
                        )
                      }
                      if (q.number > 0) {
                        kindsNumberNumberMap1[q.kindsNumber] = -q.number
                      }
                    }
                  }
                }
                console.log(kindsNumberNumberMap1)
                let obj = {
                  cutTime: this.checkDate,
                  kindsNumberMap: kindsNumberNumberMap1,
                  warehouseNo: No
                }
                console.log(obj)
                Automatic(JSON.stringify(obj)).then(res => {
                  console.log(res.data)
                  if (res.data.code == 200) {
                    var msgData = res.data.data
                    this.showTip2 = 'none'
                    this.showTip4 = 'block'
                    this.text = '提示信息'
                    this.tips = `${InsufficientList}数量不足,其余盘差成功,盘差序号: ${msgData}`
                  } else {
                    this.showTip2 = 'none'
                    this.showTip3 = 'block'
                    this.text = '提示信息'
                  }
                })
              } else {
                this.showTip2 = 'none'
                this.showTip3 = 'none'
                this.showTip = 'none'
                this.text = '提示信息'
                this.$message.error({
                  message: '此序号下所有货号库存均不足',
                  offset: 400
                })
                // if(InsufficientList != ''){this.tips1 = `${InsufficientList}数量不足`}else{this.tips1 = ''}
              }
            }
          })
        } else {
          this.$message.error({
            message: '密码错误'
          })
        }
      })
    },
    //仓库编号失去焦点
    warehouseNoBlur() {
      if (this.warehouseNo != '') {
        for (const i of this.warehouseNoList) {
          if (this.warehouseNo == i.value) {
            this.warehouseName = i.label
            return
          }
        }
        this.$message({
          type: 'warning',
          message: '无此仓库编号'
        })
        this.warehouseNo = ''
        this.warehouseName = ''
      } else {
        this.warehouseName = ''
      }
    },
    Shgd() {
      if (this.details == '') {
        this.$message({
          type: 'warning',
          message: '请选中左表进行改单'
        })
        return
      }
      for (let c of this.Aff) {
        if (c.affirm == 1) {
          this.$message({
            type: 'warning',
            offset: 400,
            message: '此单已确认，不可进行改单操作'
          })
          return
        }
      }
      this.showpwd = 'block'
    },
    showRevision() {
      this.showpwd = 'none'
      this.showod = 'block'
    },

    isChecked() {
      console.log(this.tableData)
      var warehouseNo1 = this.tableData[0].warehouseCheckList[0].warehouseNo
      var mergeData = []
      this.tableData.forEach(e => {
        e.warehouseCheckList.map((value, index, array) => {
          mergeData = mergeData.concat(value) //tableData下warehouseCheckList数组合并成一个数组
        })
      })
      console.log(mergeData)

      var tmp = {}
      for (let c in mergeData) {
        //数组内 货号相同的 数量就相加
        var key = mergeData[c].kindsNumber
        if (tmp[key]) {
          tmp[key].kindsNumber = mergeData[c].kindsNumber
          tmp[key].stockingNumber += mergeData[c].stockingNumber
        } else {
          tmp[key] = {}
          tmp[key].kindsNumber = mergeData[c].kindsNumber
          tmp[key].stockingNumber = mergeData[c].stockingNumber
        }
      }
      var sendData = []
      for (let d in tmp) {
        sendData.push(tmp[d])
      }
      // console.log(sendData)
      let kindsNumber1 = {}
      let warehouseMap1 = {}
      sendData.forEach(e => {
        kindsNumber1[e.kindsNumber] = e.stockingNumber
        warehouseMap1[e.kindsNumber] = e.warehouseName
      })
      let obj1 = {
        kindsNumberMap: kindsNumber1,
        warehouseNo: warehouseNo1
      }
      console.log(obj1)
      this.Dis = false

      this.tList = this.tList2

      getDifference(JSON.stringify(obj1)).then(res => {
        console.log(res.data)
        if (res.data.code == 200) {
          this.tableData3 = res.data.data
          this.tableData1 = this.tableData3
        }
      })
    }
  },
  watch: {
    kindsNumber(a, b) {
      if (a) {
        this.kindsNumber = a.toUpperCase().trim()
      }
    },
    receiptsNumber(a, b) {
      if (a) {
        this.receiptsNumber = a.toUpperCase().trim()
      }
    },
    checked(a, b) {
      if (a) {
        this.isChecked()
      } else {
        this.tList = this.tList1
        this.Dis = true
        this.tableData1 = this.tableData2
      }
    }
  }
}
</script>
<style scoped>
.warehouseTakeStockQuery {
  margin-right: 15px;
  padding: 0 15px;
  background-color: white;
  height: 94.5vh;
  position: relative;
}
.wdq-top {
  padding: 15px 0;
  border-bottom: 2px solid #f4f4f4;
}
.wdq-top div {
  display: flex;
}
.wdq-top div p:first-child {
  margin: 3px 6px 0 0;
  display: inline-block;
  white-space: nowrap;
}
.wdq-top div p:not(:first-child) {
  margin: 3px 6px 0 12px;
  display: inline-block;
  white-space: nowrap;
}
.wd {
  width: 160px;
}
.wdq-btn {
  padding: 15px 0;
  display: flex;
  justify-content: space-between;
}
.wdq-tab {
  display: flex;
}
.wdq-tab > div:first-child {
  width: 28%;
  padding-right: 1%;
  text-align: end;
}
.wdq-tab > div:nth-child(2) {
  width: 72%;
  padding-left: 1%;
  border-left: 2px solid #f4f4f4;
  text-align: end;
}
.footView span {
  float: left;
  margin-right: 48px;
  line-height: 6vh;
  font-size: 14px;
}
.footView span i {
  margin-right: 5px;
}
.print {
  top: 14%;
  left: 16%;
}
.tip {
  position: absolute;
  top: 30%;
  left: 40%;
  background: white;
  width: 400px;
  height: 210px;
  /* border: 1px solid black; */
  box-shadow: 0 3px 3px 3px #f4f4f4;
  z-index: 99;
}
.tip > div:first-child {
  background: #f4f4f4;
  display: flex;
  justify-content: space-between;
  padding: 10px 15px;
  font-weight: 700;
}
.tip1 {
  padding: 30px 15px 10px 15px;
  text-align: center;
}
.tip1 div:last-child {
  padding: 0 15px;
  margin-top: 20px;
  text-align: end;
}
</style>

<style>
.warehouseTakeStockQuery .wdq-top .el-input__inner {
  height: 30px;
}
.warehouseTakeStockQuery .wdq-top .el-date-editor .el-range__icon {
  line-height: 23px;
}
.warehouseTakeStockQuery .wdq-top .el-date-editor .el-range-separator {
  width: 8%;
  line-height: 23px;
}
.warehouseTakeStockQuery .wdq-top .el-date-editor .el-range__close-icon {
  line-height: 23px;
}
.warehouseTakeStockQuery .wdq-top .el-date-editor--daterange.el-input__inner {
  width: 380px;
}
.warehouseTakeStockQuery .wdq-top .el-input__icon {
  line-height: 30px;
}
.warehouseTakeStockQuery .wdq-btn .el-checkbox.is-bordered {
  height: 30px;
  padding: 4px 10px 0px 10px;
}
.warehouseTakeStockQuery .tip .tip1 .el-input__inner {
  height: 30px;
}

.warehouseTakeStockQuery
  .wdq-tab
  .el-pagination
  .el-select
  .el-input
  .el-input__inner {
  width: 100px;
  height: 30px;
}
.warehouseTakeStockQuery .wdq-tab .el-pagination--small .el-pagination__editor,
.el-pagination--small .el-pagination__editor.el-input .el-input__inner {
  width: 50px;
  height: 30px;
  margin-right: 5px;
}
.warehouseTakeStockQuery
  .wdq-tab
  .el-pagination.is-background.el-pagination--small
  .btn-next,
.el-pagination.is-background.el-pagination--small .btn-prev,
.el-pagination.is-background.el-pagination--small .el-pager li {
  height: 30px;
  width: 30px;
}
.warehouseTakeStockQuery .wdq-tab .el-pagination--small button,
.el-pagination--small span:not([class*='suffix']) {
  margin-right: 10px;
}
</style>
